/******************************************************************
 * Created by: GOh CHee Hong                                      
 * Date of Creation: 1/Jan/2009            
 
 *                                                                
 * Description: This class is in charge of publishing the IP to the OpenLookUp network
 ******************************************************************/

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using Pbdms.Common.SharedVariables;
namespace Pbdms.BusinessLogic.PeerMS
{
    public class IDPublisher
    {
        SecretKeyControl secretKeyControl;
        public IDPublisher()
        {
            
        }
        public IDPublisher(SecretKeyControl keyControl)
        {
            this.secretKeyControl = keyControl;
        }
        public void publish()
        {
            OpenDHTLib.OpenLookUp gateway = new Pbdms.OpenDHTLib.OpenLookUp();
            while (true)
            {
                    gateway.Put(secretKeyControl.readSecretKey().PublicKey.KeyId.ToString("X"), Common.Global.getIP().ToString(), 600);
                    //sleep for 1 min
                    Thread.Sleep(60000);                
            }
        }
    }
}
